package com.mvc.dao.impl;

import com.mvc.dao.TeacherDao;
import com.mvc.pojo.Teacher;
import com.mvc.util.DruidUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

public class TeacherDaoImpl implements TeacherDao {

    private JdbcTemplate jt = new JdbcTemplate(DruidUtils.getDataSource());

    @Override
    public List<Teacher> findAll() {
        List<Teacher> teachers = jt.query("select * from teacher", new BeanPropertyRowMapper<Teacher>(Teacher.class));
        return teachers;
    }
}
